<!DOCTYPE html>
<html>
<head>
	<meta charset="utf-8">
	<title>Generator</title>
</head>
<body>
<script>
function* test01() {
    let aa = 999;
    console.log(11);
    yield '01';
    console.log(aa);
    console.log(12);
    yield '02';
    console.log(13);
    yield '03';
    console.log(14);
    yield '04';
    console.log(15);
}
var testObj01 = test01();//代码并没有被执行,没有输出11
console.log(typeof testObj01);//object
//先输出:11
//{value: "01", done: false}
console.log(testObj01.next());
//先输出:999
//先输出:12
//{value: "02", done: false}
console.log(testObj01.next());//{value: "02", done: false}
//先输出:13
//{value: "03", done: false}
console.log(testObj01.next());//{value: "03", done: false}
</script>
</body>
</html>